Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

end-to-end tests in circleci [CUMULUS-371] #238

Merged
merged 11 commits into from
Mar 9, 2018
Merged

end-to-end tests in circleci [CUMULUS-371] #238

merged 11 commits into from
Mar 9, 2018

Conversation

scisco
Copy link
Contributor

@scisco scisco commented Mar 8, 2018

Summary: Summary of changes

Addresses CUMULUS-371

Changes

  • Adds local integration testing and runs them in circleci

Test Plan

Things that should succeed before merging.

  • Unit tests

@scisco scisco changed the title [WIP] end-to-end tests in circleci [CUMULUS-371] end-to-end tests in circleci [CUMULUS-371] Mar 9, 2018
* @param {integer} receiptHandle - the unique identifier of the sQS message
* @returns {Promise} an AWS SQS response
*/
exports.deleteSQSMessage = async (queueUrl, receiptHandle) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no await here so I don't think the async declaration is necessary

const filename = 'cumulus-message-adapter.zip';
context.src = path.join(process.cwd(), 'tests', `${randomString()}.zip`);
context.dest = path.join(process.cwd(), 'tests', randomString());
await fetchMessageAdapter(null, gitPath, filename, context.src, context.dest);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since these lines of code are duplicated in tests/ftp_pdr_parse_ingest.js could we extract it into a function intestUtils (or the fetchMessageAdapter function itself)?

@@ -0,0 +1,55 @@
{
"DiscoverPdrs": {
Copy link
Contributor

@abarciauskas-bgse abarciauskas-bgse Mar 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor style thing but elsewhere in this repo we're using 2 spaces for indentation so preference would be to be consistent with 2 spaces. Here and in other .json files in this PR


let stepInput = clone(message);

for (const step of workflow.steps) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious - is there a reason to use this iteration syntax over workflowSteps.forEach((step) => { ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has to happen in sequence. If we don't use for of, we have to use some other library to ensure each async task happen after the other one ended.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that makes sense

let stepInput = clone(message);

for (const step of workflow.steps) {
stepInput = await runStep(step.lambda, step.handler, stepInput, step.name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: missing trailing semi-colon

}
trail.output = clone(stepInput);

return trail;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think trail is a promise, as documentation suggests is returned from this function but I could be missing something

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is an async/await function so it always return a promise.

task[moduleFunctionName](message, {}, (e, r) => {
if (e) return reject(e);
console.log(`Completed execution of ${stepName}`);
return resolve(r);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think a return is necessary before reject and resolve since this function returns the Promise itself

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's good practice to return something in a function if possible.

message.cumulus_meta.task = stepName;

try {
// add message adapter to task folder
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comment out of date? Looks add message adapter is done explicitly in calling copyCMAToTask in tests

const dest = path.join(taskFullPath, 'cumulus-message-adapter');
let resp;

process.env.CUMULUS_MESSAGE_ADAPTER_DIR = dest;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this being used? I could be missing something but it seems like all this message adapter work went into copyCMAToTask and some of these lines could be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, that is used inside the python code

* @param {Array} cfOutputs - mocked outputs of a CloudFormation template
* @returns {Object} the generated cumulus message
*/
function messageBuilder(workflow, configOverride, cfOutputs) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking but here and elsewhere in this PR it could be more maintainable to use an object argument, e.g.

function messageBuilder({workflow, configOverride, cfOutputs})

this makes it easier to add arguments without being concerned about what order they are in when you make the function call.


return messages.Messages;
}
return [];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this function just returns an array of messages (or the empty array) (e.g. not {Promise.<Array>} as documentation above indicates

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

async/await function always return a promise.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right! I learned something.

Copy link
Contributor

@abarciauskas-bgse abarciauskas-bgse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made some comments but none of them are really blocking - let me know when I should take another 👀

👏 great work!

@scisco scisco merged commit 1c5ce4c into master Mar 9, 2018
@scisco scisco deleted the CUMULUS-371 branch March 9, 2018 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants